class Solution
{
public:
    vector<int> smallerNumbersThanCurrent(vector<int> &nums)
    {
        int numCount[101] = {0};
        for (int num : nums)
        {
            ++numCount[num];
        }
        for (int i = 1; i <= 100; ++i)
        {
            numCount[i] += numCount[i - 1];
        }
        for (int &num : nums)
        {
            if (num != 0)
            {
                num = numCount[num - 1];
            }
        }
        return nums;
    }
};